package Code.Test3;

public class GoodsTest {
    public static void main(String[] args) {
        //创建数组
        Goods[] arr = new Goods[3];

        //创建三个商品对象
        Goods g1 = new Goods("a1","华为P40",5999.0,100);
        Goods g2 = new Goods("a2","保温杯",227.0,50);
        Goods g3 = new Goods("a3","枸杞",12.7,70);

        //把商品添加进数组
        arr[0] = g1;
        arr[1] = g2;
        arr[2] = g3;

        //遍历
        for (int i = 0; i < arr.length; i++) {
            Goods goods = arr[i];
            System.out.println("id："+goods.getId()+",名称："+goods.getName()+",价格："+
                    goods.getPrice()+",库存："+goods.getCount());
        }
    }
}
